package Offer.offer2018;

/**
 * 按年龄排序
 * Created by 雷文康 on 2018/3/3.
 */
public class Test07b {
    public static void main(String[] args) {
        int[] ages = {5,3,7,15,7,2,6,3,6,2,66,7,2,78,24,23,67};
        sortAge(ages);
    }

    public  static void sortAge(int[] array){
        //假设最大年龄为99
        int maxAge = 99;
        int[] ages = new int[maxAge + 1];
        for (int i = 0; i < array.length; i++) {
            ages[array[i]]++;
        }
        for (int i = 0; i < ages.length; i++) {
            for (int j = 0; j < ages[i]; j++) {
                System.out.print(i);
                System.out.print(" ");
            }
        }


    }
}
